<!doctype html>
<html>
<head>
<!-- 声明文档使用的字符编码 -->
<meta charset='utf-8'>
<!-- 优先使用 IE 最新版本和 Chrome -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<!-- 页面描述 -->
<meta name="description" content="不超过150个字符"/>
<!-- 页面关键词 -->
<meta name="keywords" content=""/>
<!-- 网页作者 -->
<meta name="author" content="guo,1057540638@qq.com"/>
<!-- 搜索引擎抓取 -->
<meta name="robots" content="index,follow"/>
<!-- 为移动设备添加 viewport -->
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=3,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,target-densityDpi=medium-dpi, minimal-ui" />
<!-- `width=device-width` 会导致 iPhone 5 添加到主屏后以 WebApp 全屏模式打开页面时出现黑边 http://bigc.at/ios-webapp-viewport-meta.orz -->

<!-- iOS 设备 begin -->
<meta name="apple-mobile-web-app-title" content="标题">
<!-- 添加到主屏后的标题（iOS 6 新增） -->
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!-- 是否启用 WebApp 全屏模式，删除苹果默认的工具栏和菜单栏 -->

<!--meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL" -->
<!-- 添加智能 App 广告条 Smart App Banner（iOS 6+ Safari） -->
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<!-- 设置苹果工具栏颜色 -->
<meta name="format-detection" content="telphone=no, email=no"/>
<!-- 忽略页面中的数字识别为电话，忽略email识别 -->

<!-- 启用360浏览器的极速模式(webkit) -->
<meta name="renderer" content="webkit">
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 不让百度转码 -->
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
<meta name="HandheldFriendly" content="true">
<!-- 微软的老式浏览器 -->
<meta name="MobileOptimized" content="320">
<!-- uc强制竖屏 -->
<meta name="screen-orientation" content="portrait">
<!-- QQ强制竖屏 -->
<meta name="x5-orientation" content="portrait">
<!-- UC强制全屏 -->
<meta name="full-screen" content="yes">
<!-- QQ强制全屏 -->
<meta name="x5-fullscreen" content="true">
<!-- UC应用模式 -->
<meta name="browsermode" content="application">
<!-- QQ应用模式 -->
<meta name="x5-page-mode" content="app">
<!-- windows phone 点击无高光 -->
<meta name="msapplication-tap-highlight" content="no">
<!-- iOS 图标 begin -->
<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png"/>
<!-- iPhone 和 iTouch，默认 57x57 像素，必须有 -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png"/>
<!-- Retina iPhone 和 Retina iTouch，114x114 像素，可以没有，但推荐有 -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png"/>
<!-- Retina iPad，144x144 像素，可以没有，但推荐有 -->
<!-- iOS 图标 end -->

<!-- iOS 启动画面 begin -->
<link rel="apple-touch-startup-image" sizes="768x1004" href="img/App-ios-logo-152x152.png"/>
<!-- iPad 竖屏 768 x 1004（标准分辨率） -->
<link rel="apple-touch-startup-image" sizes="1536x2008" href="img/App-ios-logo-152x152.png"/>
<!-- iPad 竖屏 1536x2008（Retina） -->
<link rel="apple-touch-startup-image" sizes="1024x748" href="img/App-ios-logo-152x152.png"/>
<!-- iPad 横屏 1024x748（标准分辨率） -->
<link rel="apple-touch-startup-image" sizes="2048x1496" href="img/App-ios-logo-152x152.png"/>
<!-- iPad 横屏 2048x1496（Retina） -->

<link rel="apple-touch-startup-image" href="img/App-ios-logo-152x152.png"/>
<!-- iPhone/iPod Touch 竖屏 320x480 (标准分辨率) -->
<link rel="apple-touch-startup-image" sizes="640x960" href="img/App-ios-logo-152x152.png"/>
<!-- iPhone/iPod Touch 竖屏 640x960 (Retina) -->
<link rel="apple-touch-startup-image" sizes="640x1136" href="img/App-ios-logo-152x152.png"/>
<!-- iPhone 5/iPod Touch 5 竖屏 640x1136 (Retina) -->
<!-- iOS 启动画面 end -->

<!-- iOS 设备 end -->
<meta name="msapplication-TileColor" content="#000"/>
<!-- Windows 8 磁贴颜色 -->
<meta name="msapplication-TileImage" content="icon.png"/>
<!-- Windows 8 磁贴图标 -->

<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml"/>
<!-- 添加 RSS 订阅 -->
<link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>
<!-- 添加 favicon icon -->
<!-- sns 社交标签 begin -->
<!-- 参考微博API -->
<meta property="og:type" content="类型" />
<meta property="og:url" content="URL地址" />
<meta property="og:title" content="标题" />
<meta property="og:image" content="图片" />
<meta property="og:description" content="描述" />
<!-- sns 社交标签 end -->
<title>首页</title>
<link rel="stylesheet" href="__INDEX__/css/common.css">
<link rel="stylesheet" href="__INDEX__/css/font.css">
<link rel="stylesheet" href="__INDEX__/css/header.css">
<link rel="stylesheet" href="__INDEX__/css/footer.css">
<link rel="stylesheet" href="__INDEX__/css/index.css">
<link rel="stylesheet" href="__INDEX__/css/responsive.css">
</head>

<body ontouchstart="return true;">
	<!--头部-->
	<header class="search" id="search">
		<meta charset="utf-8" />
		<div class="header">
			<h1 style="margin: 0 auto;"><img src="__INDEX__/img/logo.png" style="margin: 0 auto;"></h1>
			<!--<div class="search-box" id="search-box" style="color: #FFFFFF;"></div>-->
			<div class="head-delivery head-r" id="Delivery"><i class="icon-address"></i><span id="head-delivery">选择配送点</span></div>
		</div>
		<!--通知公告/客服电话-->
	</header>

	<!--搜索内容-->
	<div class="search-content" id="search-content">
		<i class="icon-font"></i>
	</div>

	<!--内容区-->
	<article class="main-container">
		
		<!--左侧栏目-->
		<div class="sortNav" id="sortNav">
			<!--<a href="#" class="icon-stars">活动专区</a>
			<p class="icon-sort line">分类导航</p>-->
			<!--<a href="#" class="select">全部</a>-->
			<!--<a href="#">肉类禽蛋</a>-->
			<!--<a href="#">蔬菜水果</a>
			<a href="#" class="select">肉类禽蛋</a>
			<a href="#">乳品面点</a>
			<a href="#">海鲜水产</a>
			<a href="#">零食冲饮</a>
			<a href="#">粮油副食</a>
			<a href="#">干    货</a>
			<a href="#">礼    包</a>
			<a href="#">乳品面点</a>
			<a href="#">海鲜水产</a>
			<a href="#">零食冲饮</a>
			<a href="#">粮油副食1</a>-->
		</div>
		
		<!--右侧产品-->
		<div class="sortContent line">
			<!--活动列表-->
			<div class="Activity" style="display: none;">
				<ul>
					<li><img src="__INDEX__/img/slide01.webp" alt=""></li>
					<li><img src="__INDEX__/img/slide02.jpg" alt=""></li>
					<li><img src="__INDEX__/img/slide03.jpg" alt=""></li>
					<li><img src="__INDEX__/img/slide05.jpg" alt=""></li>
					<li><img src="__INDEX__/img/slide06.jpg" alt=""></li>
					<li><img src="__INDEX__/img/slide07.jpg" alt=""></li>
					<li><img src="__INDEX__/img/slide08.jpg" alt=""></li>
				</ul>
			</div>
			<!--产品列表-->
			<ol class="list-content" id="list-content" style="display: ;">

			</ol>
			<br><br>
		</div>
		
		<!--购物车-->
		<div class="cartContent fadeInBottom100" id="cartContent">
			
			<div class="LayerHeader line">
				<button class="Del"><i class="icon-delete"></i>清空</button>
				<button class="close pl"><i class="icon-plus rot45"></i></button>
			</div>
			
			<div class="cartContentList">
				<ul class="line-li" id="carlist">

				</ul>
			</div>
			
			<div class="LayerFooter">
				共计：¥<span id="totals">0.00</span>
			</div>
		</div>
			
		<!--产品介绍-->
		<div class="DetailContent fadeInBottom100 spxq" id="DetailContent spxq">						
			<div class="LayerHeader">
				<button class="button"><span class="close"><i class="icon-plus rot45"></i></span></button>
			</div>
			
			<div class="DetailContentBox">

			</div>
		</div>		

		
		<!--配送点-->
		<div class="DeliveryContent fadeInBottom100" id="DeliveryContent">

			<div class="FilterContentList">
		
				<p>郴州市</p>
				<ul id ="arealist">
					<li><span class="select icon-correct" value="1" id="area1" onclick="getarea(1)">苏仙区</span></li>
					<li><span value="2" id="area2" onclick="getarea(2)">北湖区</span></li>
					<li><span value="3" id="area3" onclick="getarea(3)">桂阳</span></li>
					<li><span value="4" id="area4" onclick="getarea(4)">资兴</span></li>
				</ul>
	
			</div>
			
		</div>


	</article>

	<!--底部栏目-->
	<menu>
		<a href="tel:18507996886"><i class="icon-tel"></i>电话</a>
		<a href="{:url('member/member_order')}"><i class="icon-allorders"></i>订单</a>
		<a href="javascript:void(0)" id="orderCart"><i class="icon-cart"><span id="carnum">0</span></i>购物车</a>
		<a href="{:url('member/index')}"><i class="icon-head"></i>我的</a>
		<a><button onclick="zhifu()" >去结算</button></a>
	</menu>
	
	<!--弹出圈圈loading-->
	<div class="spinner" style="display: none;"><i></i></div>
	
	<!--弹出loading-->
	<div class="msg-loading" style="display: none;">
		<div class="msg-box">
			<div class="msg-load">
				<p>loading<span class="dotting"></span></p>
			</div>
			<div class="msg-top"></div>
			<div class="msg-left"></div>
			<div class="msg-right"></div>
		</div>
	</div>
	<input type="hidden" id="agent_id" value="1" />
</body>
</html>
{include file="public/footer" /}
<script type="text/javascript" src="__INDEX__/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="__INDEX__/js/common.js"></script>
<script type="text/javascript" src="__INDEX__/js/layui.js"></script>
<script>
	var list={};
	var cart={};
	var lists={};
	var listss={};
	function set_goods(goods){
		append_html = "";
		for(var g in goods){
			var gd = goods[g];
			append_html+=set_gd(gd);
		}
		return append_html;
	}
	
	function set_gd(gd){
		var append_html='<li class="line" data-unit='+gd['unit'] +' data-id='+gd['goods_id']+' data-price='+gd['sale_price']+ ' data-name='+gd['goods_name']+'><a>'+
					'<a href="#" class="goodsinfo" onclick="goods_click('+gd['goods_id']+')">'+
						'<div class="pro-img"><img src="'+gd['logo']+'" alt=""></div>'+
						'<div class="pro-con"><h3>'+gd['goods_name']+'</h3><font>瘦肉多，绝对超值精排 </font><b>¥'+gd['sale_price']+'</b><p>乐果派旗舰店</p></div>'+
					'</a>'+
					'<a href="#" onclick="addcar('+gd['goods_id']+')" class="list-cart" data-unit='+gd['unit'] +' data-id='+gd['goods_id']+' data-price='+gd['sale_price']+ ' data-name='+gd['name']+'><i class="icon-cartadd"></i></a>'+
				'</li>';
		return append_html;
	}

	getgoods($("#agent_id").val());
	function getgoods(agent_id){
		$.ajax({
         	type:"post",
            url:"{:url('index/getgoodcate')}",
            data:{
            	agent_id : agent_id
            },
            success:function(data){
            	listss = data.restj;
				var type = data.type;
				var type_html = '<a href="#" class="icon-stars">活动专区</a>'+
								'<p class="icon-sort line">分类导航</p>'+
								'<a href="#" class="select">全部</a>';
						
				if(type){
					for(var t in type){
						type_html+='<a data-name='+type[t]['name'] +' data-id='+type[t]['id'] +'>'+type[t].name+'</a>';
					}
					$(".sortNav").html(type_html);
					setEvent();
				}
				var res = data.res;
				var ress = data.ress;				
				if(res){
					list=res;
					lists=ress;
					var append_html = "";
					for(var r in res){
						var goods = res[r];
						append_html+=set_goods(goods);
					}
					$(".list-content").html(append_html);
				}
            }
        });
	}
	
	//活动专区
	
	//分类选择商品
	function setEvent(){
		$(".sortNav a").click(function(){
			$('.sortNav .select').removeClass("select");
			$(this).addClass("select");
			if(!$.isEmptyObject(list)){
				var cate_id = $(this).attr('data-id');
				var append_html="";
				if(cate_id){
					var goods = list[cate_id];
					append_html=set_goods(goods);
				}else{
					if(list){
						for(var r in list){
							var goods = list[r];
							append_html+=set_goods(goods);
						}
					}
				}
				$(".list-content").html(append_html);
			}
		})
		
		$(".icon-stars").click(function(){
			if(!$.isEmptyObject(listss)){
				var append_html="";
				if(listss){
					for(var r in listss){
						var goods = listss[r];
						append_html+=set_goods(goods);
					}
				}					
			}
			$(".list-content").html(append_html);
		})
	}
	
	//选择分类， 显示商品
	function goods_click(goods_id){
		$(".spxq").css("display","block");
		if(!$.isEmptyObject(lists)){
			var goods = lists[goods_id];
			if(goods){
				var append_html = '<div class="D-slide"><img src="'+ goods[0]["logo"]+'" alt=""></div>'+
						'<div class="D-head line">'+
							'<h2>'+ goods[0]["goods_name"]+'</h2>'+
							'<font></font>'+
						'</div>'+
						'<div class="D-pro-content line">'+
							'<span>'+ goods[0]["content"]  +'</span>'+
						'</div>'+
					'</div>'+
					'<div class="LayerFooter">价格：<span>¥'+ goods[0]["sale_price"]+'</span>'+
						'<button onclick="addcar('+goods_id+')">加入购物车</button>'+
					'</div>';
				$(".DetailContentBox").html(append_html);			
			}
			setEvents();
		}
	}
	
	//关闭商品详情
	function setEvents(){
		$(".close").click(function(){
			$(".DetailContent").css("display","none");
		})
	}
	
	
	//加入购物车
	function  addcar(goods_id){
		if(!$.isEmptyObject(lists)){
			$(".cartContent").css("display","block");
			$(".spxq").css("display","none");
			var goods = lists[goods_id];
			var good = cart[goods_id];
			if(good){
				good['num']=good['num']+1;
				cart[goods_id]=good;
				var gd=$("#gd_"+goods_id);
				var gd_num=parseFloat(gd.val());
				gd.val(gd_num+1);
				$("#totals").text((parseFloat($("#totals").text())+parseFloat(cart[goods_id]['sale_price'])).toFixed(2));
			}else{
				$("#nums").text(parseFloat($("#nums").text())+1)
				good={};
				good["id"]=goods_id;
				good['sale_price']=goods[0]['sale_price'];
				good['name']=goods[0]['goods_name'];
				good['num']=1;
				good['unit']=$(this).data("unit");
				good['logo']=goods[0]['logo'];
				cart[goods_id]=good;
				var add_html='<li>'+
								'<img src="'+good['logo']+'" alt=""><p>'+good['name']+'</p><span>¥'+good['sale_price']+'</span>'+
								'<div class="D-BuyNum"><button>'+
								'<i class="icon-reduce" onclick="ms_num(this,'+goods_id+')"></i>'+
								'</button><input onchange="change(this,'+goods_id+')"    id="gd_'+goods_id+'" type="number" class="line" value="1"><button>'+
								'<i class="icon-plus" onclick="add_num(this,'+goods_id+')"></i>'+
								'</button></div>'+
							'</li>';
				$("#carlist").append(add_html);
				$("#carnum").text(parseFloat($("#carnum").text())+1)
				$("#totals").text((parseFloat($("#totals").text())+parseFloat(goods[0]['sale_price'])).toFixed(2));
				setEventsclosel();
			}
		}
	}
	
	function add_num(obj,id){
		var num=parseFloat(cart[id]['num']);
		cart[id]['num']=num+1;
		$("#totals").text((parseFloat($("#totals").text())+parseFloat(cart[id]['sale_price'])).toFixed(2));
		$("#gd_"+id).val(num+1);
	}
	function ms_num(obj,id){
		var num=parseFloat(cart[id]['num']);
		if(num>=1){
			cart[id]['num']=num-1;
			$("#gd_"+id).val(num-1);
			$("#totals").text((parseFloat($("#totals").text())-parseFloat(cart[id]['sale_price'])).toFixed(2));
		}
	}
	
	function change(obj,id){
		var v=$(obj).val();
		if(v==""||isNaN(v)){
			$(obj).val(cart[id]['num']);
		}else if($(obj).val()<=0){
			$(obj).val(0);
		}
		cart[id]['num']=$(obj).val();
		set_price();
	}
	
	function set_price(){
		if(!$.isEmptyObject(cart)){
			var total_price=0;
			for(var o in cart){
				total_price+=cart[o]['num']*cart[o]['sale_price'];
			}
			$("#totals").text(total_price.toFixed(2));
		}else{
			$("#totals").text(0.00);
		}
	}
	
	//关闭商品详情
	function setEventsclosel(){
		$(".close").click(function(){
			$(".cartContent").css("display","none");
		})
	}
	
	//清空
	$(".Del").click(function(){		
		gwcqk();
	})
	
	//清空购物车
	function gwcqk(){
		$('#carlist').html('');
		$('#nums').text(0);
		$("#totals").text(0.00);
		$("#carnum").text(0);
		cart={};
		$(".cartContent").css("display","none");
	}
	
	//购物车
	$(".icon-cart").click(function(){
		if($.isEmptyObject(cart)){		
			layer.msg("请选购商品！");
			return;
		}

		if(!$.isEmptyObject(cart)){
			var add_html = '';
			for(var o in cart){
				add_html +='<li>'+
								'<img src="'+cart[o]['logo']+'" alt=""><p>'+cart[o]['name']+'</p><span>¥'+cart[o]['sale_price']+'</span>'+
								'<div class="D-BuyNum"><button>'+
								'<i class="icon-reduce" onclick="ms_num(this,'+cart[o]['id']+')"></i>'+
								'</button><input onchange="change(this,'+cart[o]['id']+')"    id="gd_'+cart[o]['id']+'" type="number" class="line" value="'+cart[o]['num']+'"><button>'+
								'<i class="icon-plus" onclick="add_num(this,'+cart[o]['id']+')"></i>'+
								'</button></div>'+
							'</li>';				
			}
			$(".line-li").html(add_html);
		}
		setEventsclosel();
	})
	
	function zhifu1() {
		if($.isEmptyObject(cart)){
			layer.msg("购物车为空!");
			return ;
		}

		var url = '/index/index/order';
	  	parent.location.href = url;

	}
	
	//跳订单支付页面
	function zhifu() {
		var user_id = '{$user_id}';
		if(user_id==''){
	    	layer.msg("请先登陆!", {
			  icon: 1,
			  time: 2000 //2秒关闭（如果不配置，默认是3秒）
			}, function(){
				var url = '/index/member/index';
			  	parent.location.href = url;	
			});
			return;
		}
		
		if($.isEmptyObject(cart)){
			layer.msg("购物车为空!");
			return ;
		}

	  	$("#page").css("display","none");
	  	$("#orderpage").css("display","block");
	  	$('#price').text($("#totals").text());
	  	$('#sfprice').text((parseFloat($("#totals").text())+parseFloat($("#yf").text())).toFixed(2));
	  	
	  	
	  	$.ajax({
			url: "{:url('member/ordertj')}",
			type: 'POST',
			data: {
				agent_id : $("#agent_id").val(),
				price : $("#totals").text(),
				goods : cart,
				memo : $("#memo").text(),
				ztaddress : $(".ztaddress").text(),
				pay_type : 1
			},
			//成功了的回调，并且带有返回值
			success: function(data) {
				var text = data.data;
				if(data.code==200){
					var url = '/index/member/orderzf?agent_id='+text.agent_id+'&&sfprice='+ text.sfprice;
					parent.location.href = url;		
                }else{
                	layer.msg(data.msg);//保存成功提示
                	if(data.code==403){		
						$("#Add-Address-Content").css("display","block");                   		
                	}
                }

			}
		})
	  	
	}
	
	//支付
	function tjorder(){
		if($.isEmptyObject(cart)){
			layer.msg("账单为空!");
			return ;
		}
		
		var psfs = $("#orderDelivery ol li span.select").text();
		if(psfs=='上门自提'){
			var ztadress = $(".ztaddress").text();
			if(!ztadress){
				layer.msg("请选择地址!");
				return ;			
			}			
		}
		
		$.ajax({
			url: "{:url('member/ordertj')}",
			type: 'POST',
			data: {
				agent_id : $("#agent_id").val(),
				price : $("#sfprice").text(),
				goods : cart,
				memo : $("#memo").text(),
				ztaddress : $(".ztaddress").text(),
				pay_type : 1
			},
			//成功了的回调，并且带有返回值
			success: function(data) {
				if(data.code==200){
                	layer.msg(data.msg, {
					  icon: 1,
					  time: 1000 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						var url = '/index/index/ordertj';
					  	parent.location.href = url;		
					});
                }else{
                	layer.msg(data.msg);//保存成功提示
                	if(data.code==403){		
						$("#Add-Address-Content").css("display","block");                   		
                	}
                }

			}
		})
	}
	
	$(document).ready(function(){
		//配送方式
		$("#orderDelivery ol li").bind('click',function(){
			
			if($(this).index()==0){
				$("#orderPays").show();
				$("#orderDelivery ol li:nth-child(1) span").addClass("select icon-correct");
				$("#orderDelivery ol li:nth-child(2) span").removeClass();
				$("#orderDelivery .order-Delivery-Pick").hide();
			}else{
				$("#orderPays").hide();
				$("#orderDelivery ol li:nth-child(1) span").removeClass();
				$("#orderDelivery ol li:nth-child(2) span").addClass("select icon-correct");
				$("#orderDelivery .order-Delivery-Pick").show();
			}
			
		})
		//支付方式
		$("#orderPayse ol li").bind('click',function(){
			
			if($(this).index()==0){
				$("#orderPayse ol li:nth-child(1) span").addClass("select icon-correct");
				$("#orderPayse ol li:nth-child(2) span").removeClass();
				$("#orderPayse ul").show();
			}else{
				$("#orderPayse ol li:nth-child(1) span").removeClass();
				$("#orderPayse ol li:nth-child(2) span").addClass("select icon-correct");
				$("#orderPayse ul").hide();
			}
			
		})
		
		//支付方式
		$("#orderPayse ul li").bind('click',function(){
			
			if($(this).index()==0){
				$("#orderPayse ul li:nth-child(1)").addClass("select");
				$("#orderPayse ul li:nth-child(2)").removeClass();
			}else{
				$("#orderPayse ul li:nth-child(1)").removeClass();
				$("#orderPayse ul li:nth-child(2)").addClass("select");
			}
			
		})
		
		var o = document.getElementById('date');

    var o = document.getElementById('time');

    
	})
	
	function getarea(type){
		gwcqk();0
		$(".sortNav").html('');
		$("#DeliveryContent").css("display","none");
		$("#orderpage").css("display","none");
		
		$(".LayerBackground").css("display","none");
		$('#arealist li span').removeClass("select icon-correct");
		$('#area'+type).addClass("select icon-correct");
		$("#agent_id").val(type);		
		getgoods(type);		
	}
	
	
	//选地址
	$("#Edit-Address").click(function(){
		$("#cartContent").css("display","none");
	});
	
	address();
	//选择地址
	function address(){
		$.ajax({
			url: "{:url('member/getaddress')}",
			type: 'POST',
			//成功了的回调，并且带有返回值
			success: function(data) {
            	var data = data.data;
            	var str = '';
            	if(data){
            		str = '<dl id="xsaddress">'+
            		'<dt><i class="icon-head"></i>'+ data['consignee'] +'&nbsp;&nbsp;<i class="icon-phone"></i>'+ data['mobile'] +'</dt>'+
					'<dd>'+ data['province'] +'&nbsp;&nbsp;'+ data['city'] +'&nbsp;&nbsp;'+ data['district'] +'&nbsp;&nbsp;'+data['address']+'</dd>';       		
            	}
				$("#Edit-Address").html(str);
			}
		})		
	}
	
	//保存地址
	function saveaddress(){
		var province = $("#province option:selected").val();
		var city = $("#city option:selected").val();
		var district = $("#district option:selected").val();
		var consignee = $("#consignee").val();
		var mobile = $("#mobile").val();
		var address = $("#address").val();
		var con = layer.confirm('确认操作?', function(index) {
			$.ajax({
				url: "{:url('member/address_add')}",
				type: 'POST',
				data: {
					province : province,
					city : city,
					district : district,
					consignee : consignee,
					mobile : mobile,
					address : address
				},
				//成功了的回调，并且带有返回值
				success: function(data) {
					if(data.code==200){
						$("#Add-Address-Content").css("display","none");
		            	var data = data.data;
		            	var str = '';
		            	if(data){
		            		str = '<dl id="xsaddress">'+
		            		'<dt><i class="icon-head"></i>'+ data['consignee'] +'&nbsp;&nbsp;<i class="icon-phone"></i>'+ data['mobile'] +'</dt>'+
							'<dd>'+ data['province'] +'&nbsp;&nbsp;'+ data['city'] +'&nbsp;&nbsp;'+ data['district'] +'&nbsp;&nbsp;'+data['address']+'</dd>';         		
		            	}
						$("#Edit-Address").html(str);
	                }else{
	                	layer.msg(data.msg);//保存成功提示
	                }
	
				}
			})
		})
	}
	
	//自提地址
	function zt_ads(){
		$.ajax({
			url: "{:url('member/getztaddress')}",
			type: 'POST',
			data: {
				agent_id : $("#agent_id").val(),
			},
			//成功了的回调，并且带有返回值
			success: function(data) {
				if(data.code==200){
					$(".order-Delivery-Pick").css("display","block");
	            	var data = data.data;
	            	var str = '';
	            	var str1 = '';
					for(var i = 0; i < data.length; i++) {
	            		str += '<li class="line"><span>地址' + (parseInt(i)+1) + '：'+ data[i].address +'</span>';
	            	}
					$(".order-Delivery-Pick").html(str);
					setEventads();
                }else{
                	layer.msg(data.msg);//保存成功提示
                }

			}
		})		
	}
	
	function setEventads(){
		$(".order-Delivery-Pick li span").click(function(){
			$('.order-Delivery-Pick li span').removeClass("ztaddress");
			$(this).addClass("ztaddress");
		});
	}
</script>